﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EarringsRecommendationWeb
{
    public abstract class CheckUserSession : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Member mem = Session["member"] as Member;

            if (mem != null)
            {
                Response.Write("<input id='hidden-email' name='hidden-email' type='hidden' value='" + mem.Email + "'>");
                Response.Write("<input id='hidden-name' name='hidden-name' type='hidden' value='" + mem.Name + "'>");
                Session["MemberEmail"] = mem.Email;
                List<RecalQty> listQty = Session["RecalQty"] as List<RecalQty>;
                int qty = 0;
                if (listQty != null)
                {
                    foreach (RecalQty item in listQty)
                    {
                        qty += Convert.ToInt32(item.Qty);
                    }
                }
                ClientScript.RegisterArrayDeclaration("qty", string.Format("\"{0}\"", qty));
            }
            else
            {
                Response.Redirect("home.aspx");
            }
        }
    }
}